-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REG-1463] Generate 'partial' class to attach RGState and RGAction to host behavior #116
Conversation
feae999
to
924323a
Compare
Resolved a gnarly enough conflict that I'd like to get re-reviews (particularly from @RG-nAmKcAz since that's where the conflict arose and I want to make sure I didn't blast away his changes). I'll do another smoke-test to make sure things are working. And I see you already approved 🤣 . Thanks @RG-nAmKcAz ! |
For clarity, I'm not hand inspecting the code to see if you merged it correctly. I would expect the dev themselves to do that as necessary. I didn't see anything obvious though at a high level glance. |
924323a
to
30c9721
Compare
Yep, that's my expectation too, but I think it's always valuable for the conflicting commit author to take a scan over it. Thanks for looking! |
There was one small style change lost in the conflict resolution. I've restored that: 16e8995 |
This updates our Unity code gen to add partial classes that create a
RequireComponent
dependency from the "host" behavior (theMonoBehavior
on which the[RGState]
or[RGAction]
attribute is placed) to the generatedRGState_[HostBehaviorName]
andRGAction_[HostBehaviorName]
components. This signals to the Unity editor, when reimporting assets, to add theRGState_...
/RGAction_...
components to anyGameObject
that also has the host behavior attached. This mostly allows us to "auto-attach" the behaviors.From my testing, this is fairly consistent. Unity does caution that it doesn't check dependencies in all scenarios, but it does it whenever
GameObject.AddComponent
is called.In order to generate this auto-attach class, we need the original host behavior to be marked as a
partial
class. I added code to check for that and report an error if that's not the case. WIth the changes in #105, this also causes a dialog to pop up to draw your attention to the log:NOTE: One additional change I made is to restore the "Generate Scripts" menu item. After #105 merged, auto-generation is mostly working but there are a few scenarios where I've noticed it doesn't work:
Both cases are fairly rare (case 1 is mostly just for us), but it seems reasonable to me to bring back the ability to manually regenerate the scripts, even if it's only needed in edge cases.
Find the pull request instructions here
Every reviewer and the owner of the PR should consider these points in their request (feel free to copy this checklist so you can fill it out yourself in the overall PR comment)